package com.xingfly.school.course.ohs.remote.controller;

import com.xingfly.school.course.ohs.local.appservices.CourseAppService;
import com.xingfly.school.course.ohs.local.pl.response.CourseStudentInfoResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 课程相关API
 * Created by SuperS on 2020/3/25.
 *
 * @author SuperS
 */
@RestController
@RequestMapping("/courses")
public class CourseController {

    @Resource
    private CourseAppService courseAppService;


    /**
     * 查询课程下的所有学生
     *
     * @param courseId 课程ID
     * @return 学生列表
     */
    @GetMapping("/{id}/students")
    public List<CourseStudentInfoResponse> findStudentsByCourseId(@PathVariable("id") Long courseId) {
        return courseAppService.findStudentsByCourseId(courseId);
    }


}
